package com.chuanjiabao.wisdom.guide;

import android.databinding.DataBindingUtil;
import android.view.LayoutInflater;
import android.view.View;

import com.blog.www.guideview.Component;
import com.blog.www.guideview.Guide;
import com.chuanjiabao.wisdom.R;
import com.chuanjiabao.wisdom.databinding.LayerLastBinding;
import com.chuanjiabao.wisdom.listener.OnBHClickListener;

public class CenterComponent implements Component {

    private OnBHClickListener onBHClickListener;
    private Guide mGuide;

    @Override
    public View getView(LayoutInflater inflater) {
        LayerLastBinding binding = DataBindingUtil.inflate(
                inflater,
                R.layout.layer_last,
                null,
                false
        );

        binding.tvModuleDone.setOnClickListener(v -> {
            if (mGuide != null) mGuide.dismiss();

            if (onBHClickListener != null) {
                onBHClickListener.onConfirmClick();
            }
        });

        return binding.getRoot();
    }

    @Override
    public int getAnchor() {
        return Component.ANCHOR_OVER;
    }

    @Override
    public int getFitPosition() {
        return Component.FIT_CENTER;
    }

    @Override
    public int getXOffset() {
        return 0;
    }

    @Override
    public int getYOffset() {
        return 0;
    }

    @Override
    public void attact(Guide guide) {
        this.mGuide = guide;
    }

    public void setOnBHClickListener(OnBHClickListener onBHClickListener) {
        this.onBHClickListener = onBHClickListener;
    }

}
